package fragmentAppl;

import java.util.ArrayList;

import tools.Debug;
import tools.FragmentState;

import tools.MMME;
import components.QuasiComponentCharacteristics;


public class Characteristics extends QuasiComponentCharacteristics {

	private ArrayList<MMME> requiredMMME;
	private ArrayList<MMME> providedMMME;
	
	private int contexteAdequacy;
	
	
	public Characteristics (ArrayList<MMME> required, ArrayList<MMME> provided, int contexte){
		if(required.size()==0)
			requiredMMME=new ArrayList<MMME>();
		else
			requiredMMME=new ArrayList<MMME>(required);
		providedMMME=new ArrayList<MMME>(provided);
		//showMMME();
		setContexteAdequacy(contexte);
	}


	@Override
	public ArrayList<MMME> getRequiredMMME() {
		//Debug.println("get req "+requiredMMME.toString());
			return requiredMMME;
	}


	@Override
	public ArrayList<MMME> getProvidedMMME() {
		return providedMMME;
	}


	@Override
	public int getContextAdequacy() {
		// TODO Auto-generated method stub
		return contexteAdequacy;
	}


	@Override
	public void addRequiredMMME(MMME requiredMMME) {
		// TODO Auto-generated method stub
		this.requiredMMME.add(requiredMMME);
	}


	@Override
	public void addProvideddMMME(MMME providedMMME) {
		// TODO Auto-generated method stub
		this.providedMMME.add(providedMMME);
	}


	@Override
	public void delateRequiredMMME(MMME requiredMMME) {
		// TODO Auto-generated method stub
		for (int i=0;i<this.requiredMMME.size();i++)
			if(this.requiredMMME.get(i).getID().equals(requiredMMME.getID()))
				this.requiredMMME.remove(i);
	}


	@Override
	public void delateProvideddMMME(MMME providedMMME) {
		// TODO Auto-generated method stub
		for (int i=0;i<this.providedMMME.size();i++)
			if(this.providedMMME.get(i).getID().equals(providedMMME.getID()))
				this.providedMMME.remove(i);
	}


	public void setContexteAdequacy(int contexteAdequacy) {
		this.contexteAdequacy = contexteAdequacy;
	}


	public int getContexteAdequacy() {
		return contexteAdequacy;
	}
	
	private void showMMME(){
		Debug.print(" provided mmme : ");
		for(MMME m: providedMMME){
			Debug.print(m.getID()+ " , ");
		}
		Debug.println(" ");
		Debug.print(" required mmme : ");
		for(MMME m: requiredMMME){
			Debug.print(m.getID()+ " , ");
		}
	}
	
	
}
